/*
 * TemperatureSensor.java
 *
 * Created on June 16, 2007, 8:29 PM
 *
 * To change this template, choose Tools | Template Manager
 * and open the template in the editor.
 */

package atag.runtime.sensors;

import com.sun.spot.sensorboard.IDemoBoard;
import com.sun.spot.sensorboard.EDemoBoard; 
import com.sun.spot.sensorboard.peripheral.ITemperatureInput;
import com.sun.spot.util.Utils;
import java.io.IOException;
/**
 *
 * @author Sirius
 */
public class TemperatureSensor implements ATaGSensor {
    
    private int maxReading;
    private int currentReading;
    
    private ITemperatureInput temperatureSensor;
    private IDemoBoard sensorBoard;
    
    /** Creates a new instance of TemperatureSensor */
    public TemperatureSensor() {
        sensorBoard = EDemoBoard.getInstance();
        temperatureSensor = sensorBoard.getADCTemperature();   //to be replaced
    }
    
 public int getMaxReading() {
        try {
            this.maxReading = (int) temperatureSensor.getRange(); // Y axis motion
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }

        return this.maxReading;
    }
    
    public int getCurrentReading() {
        int currentTemperatureValue = -1;
        try {
            currentTemperatureValue = (int)temperatureSensor.getValue();
        }
        catch (IOException ex) {
            ex.printStackTrace();
        }        

        return currentTemperatureValue;
    }
    
}
